/*
 *  Board.h
 *  RiskAI
 *
 */

#ifndef BOARD_H_INCLUDED
#define BOARD_H_INCLUDED

#include "Territory.h"
#include "Continent.h"

#include <vector>
#include <string>

class CPlayer;

class CBoard
{
public:

	CBoard();
	CBoard(bool bPrintsVisible);
	~CBoard();
	
	bool LoadFromFile(const char* sFileName);
	void Clear();		// delete territories, ready to load new file
	void WipeGame();	// clear armies and owners, ready for new game

	void BuildDistMatrix();
	void PrintDistMatrix();		// just for debugging
	int  GetDist(int iTerr1, int iTerr2);
	
	int  GetNumTerritories();
	CTerritory* GetTerritory(int iTerritoryIndex);
	
	// Assign Territories to players at random
	void AssignRandomOwnership(std::vector<CPlayer*> vpxPlayers);
	void ChooseOwnership(std::vector<CPlayer*> vpxPlayers);
	void PlaceStartingArmies(std::vector<CPlayer*> vpxPlayers, bool bRandom);
	
	bool PlayerHasWon(CPlayer* pxPlayer);
	std::vector<int> GetViableAttackers(CPlayer* pxPlayer);
	std::vector<int> GetViableFortifiers(CPlayer* pxPlayer);
	int  CalculateProduction(std::vector<int> viTerritories);
	int	 EnemiesSurroundingTerritory(int iIndex);
	
	// Prints out each Territory: Owner, Armies, and Borders
	void PrintBoardState(bool bDebug = false);
	std::string GetTerritoryInfo(int iIndex);
	
private:
	
	bool m_bPrintsVisible;
	int  m_iStartingArmies;
	
	std::vector<std::vector<int> >  m_vviDistances;
	
	std::vector<CTerritory*>  m_vpxTerritories;
	std::vector<CContinent*>  m_vpxContinents;
};

#endif // BOARD_H_INCLUDED